home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_015 / okidatadump / dumpwb.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  5KB  |  119 lines

  1. /*
  2.  *
  3.  *    DISCLAIMER:
  4.  *
  5.  *    This program is provided as a service to the programmer
  6.  *    community to demonstrate one or more features of the Amiga
  7.  *    personal computer.  These code samples may be freely used
  8.  *    for commercial or noncommercial purposes.
  9.  * 
  10.  *     Commodore Electronics, Ltd ("Commodore") makes no
  11.  *    warranties, either expressed or implied, with respect
  12.  *    to the program described herein, its quality, performance,
  13.  *    merchantability, or fitness for any particular purpose.
  14.  *    This program is provided "as is" and the entire risk
  15.  *    as to its quality and performance is with the user.
  16.  *    Should the program prove defective following its
  17.  *    purchase, the user (and not the creator of the program,
  18.  *    Commodore, their distributors or their retailers)
  19.  *    assumes the entire cost of all necessary damages.  In 
  20.  *    no event will Commodore be liable for direct, indirect,
  21.  *    incidental or consequential damages resulting from any
  22.  *    defect in the program even if it has been advised of the 
  23.  *    possibility of such damages.  Some laws do not allow
  24.  *    the exclusion or limitation of implied warranties or
  25.  *    liabilities for incidental or consequential damages,
  26.  *    so the above limitation or exclusion may not apply.
  27.  *
  28.  */
  29.  
  30. /* printer.c - program to do a raster dump to whatever printer is specified
  31.  *         by Preferences, of the Workbench Screen.  
  32.  *
  33.  * Author:  Rob Peck, 12/1/85
  34.  *
  35.  * This code may be freely utilized to develop programs for the Amiga
  36.  */
  37.  
  38. #include "exec/types.h"
  39. #include "intuition/intuition.h"
  40. #include "devices/printer.h"
  41. #include "Dump.h"
  42. #define INTUITION_WONT_OPEN 1000
  43.  
  44. union printerIO *request;    /* a pointer to a request block */
  45. extern int DumpRPort();
  46. extern int OpenPrinter();
  47. extern int ClosePrinter();
  48. extern struct IORequest *CreateExtIO();
  49. extern struct Window *OpenWindow();
  50. extern struct Port *CreatePort();
  51. struct IntuitionBase *IntuitionBase;
  52.  
  53. struct NewWindow nw = {
  54.         0, 0, 100, 40, 0, 1, 0, 0, NULL, NULL, NULL, NULL, NULL,
  55.         0, 0, 0, 0, WBENCHSCREEN
  56.         };
  57.          
  58. main()
  59. {
  60.         struct Window *w;
  61.         struct Screen *screen;
  62.         struct RastPort *rp;
  63.         struct ViewPort *vp;
  64.         struct ColorMap *cm;
  65.     union printerIO sizeDummy;
  66.         int modes,width,height,error;
  67.         struct Port *printerPort;      /* at which to receive reply */
  68.         IntuitionBase = (struct IntuitionBase *)OpenLibrary(
  69.                         "intuition.library", 0);
  70.         if (IntuitionBase == NULL) exit(INTUITION_WONT_OPEN);
  71.  
  72.         w = OpenWindow(&nw);
  73.         if(w == NULL) goto cleanup1;
  74.         screen = w->WScreen;    /* get screen address from window */
  75.         CloseWindow(w);         /* once have screen address, no
  76.                                  * more need for window, close it.
  77.                                  */
  78.         vp = &screen->ViewPort; /* get screen's ViewPort, from
  79.                                  * which the colormap will be gotten */
  80.         rp = &screen->RastPort; /* get screen's RastPort, which
  81.                                  * is what gets dumped to printer */
  82.         
  83.         cm = vp->ColorMap;      /* retrieve pointer to colormap for
  84.                                  * the printer dump */
  85.         modes = vp->Modes;      /* retrieve the modes variable */
  86.         width = vp->DWidth;     /* retrieve width to print */
  87.         height = vp->DHeight;   /* retrieve height to print */
  88.  
  89.         printerPort = CreatePort("my.print.port",0);
  90.         request =  (union printerIO *)CreateExtIO(printerPort,
  91.                                         sizeof(sizeDummy));
  92.  
  93.         error = OpenPrinter(request);
  94.         if(error != 0) goto cleanup2;
  95.  
  96.     Delay(300);    /* 300/60 = 6 seconds delay before it starts */
  97.         error = DumpRPort(
  98.                         request,/* pointer to initialized request */
  99.                         rp,     /* rastport pointer */
  100.                         cm,     /* color map pointer */
  101.                         modes,  /* low, high res, etc (display modes)*/
  102.                         0, 0,   /* x and y offsets into rastport */
  103.                         width,height, /* source size */
  104.                         width,(height * 2), /* dest rows, columns */
  105.                         SPECIAL_FULLROWS 
  106.             | SPECIAL_FULLCOLS
  107.             | SPECIAL_ASPECT /* io Special value, says print
  108.                                  * as pixels only, direct copy */
  109.                         );
  110.         ClosePrinter(request);
  111. cleanup2:
  112.         DeleteExtIO(request, sizeof(sizeDummy));
  113.         DeletePort(printerPort);
  114. cleanup1:
  115.         CloseLibrary(IntuitionBase);
  116.         
  117. }               /* end of demo screen dump */
  118.  
  119.